import { CraftingRecipe } from './types';
import { BlockType } from '@/blocks/types';

export const BASIC_RECIPES: CraftingRecipe[] = [
  // ===== 一、基础物品 (Basic Items) =====
  
  // 木板 (Planks) - 1个任意原木 -> 4个木板
  {
    id: 'planks_from_log',
    type: 'shapeless',
    pattern: [[BlockType.LOG]],
    result: { type: BlockType.PLANKS, count: 4 }
  },

  // 工作台 (Crafting Table) - 4个木板 -> 1个工作台
  {
    id: 'crafting_table',
    type: 'shaped',
    pattern: [
      [BlockType.PLANKS, BlockType.PLANKS],
      [BlockType.PLANKS, BlockType.PLANKS]
    ],
    result: { type: BlockType.CRAFTING_TABLE, count: 1 }
  },

  // 木棍 (Stick) - 2个木板 -> 4个木棍
  {
    id: 'stick',
    type: 'shaped',
    pattern: [
      [BlockType.PLANKS],
      [BlockType.PLANKS]
    ],
    result: { type: BlockType.STICK, count: 4 }
  },

  // 火把 (Torch) - 1个煤炭/木炭 + 1个木棍 -> 4个火把
  {
    id: 'torch_coal',
    type: 'shaped',
    pattern: [
      [BlockType.COAL],
      [BlockType.STICK]
    ],
    result: { type: BlockType.TORCH, count: 4 }
  },
  {
    id: 'torch_charcoal',
    type: 'shaped',
    pattern: [
      [BlockType.CHARCOAL],
      [BlockType.STICK]
    ],
    result: { type: BlockType.TORCH, count: 4 }
  },

  // 熔炉 (Furnace) - 8个圆石 -> 1个熔炉
  {
    id: 'furnace',
    type: 'shaped',
    pattern: [
      [BlockType.COBBLESTONE, BlockType.COBBLESTONE, BlockType.COBBLESTONE],
      [BlockType.COBBLESTONE, null, BlockType.COBBLESTONE],
      [BlockType.COBBLESTONE, BlockType.COBBLESTONE, BlockType.COBBLESTONE]
    ],
    result: { type: BlockType.FURNACE, count: 1 }
  },

  // 箱子 (Chest) - 8个木板 -> 1个箱子
  {
    id: 'chest',
    type: 'shaped',
    pattern: [
      [BlockType.PLANKS, BlockType.PLANKS, BlockType.PLANKS],
      [BlockType.PLANKS, null, BlockType.PLANKS],
      [BlockType.PLANKS, BlockType.PLANKS, BlockType.PLANKS]
    ],
    result: { type: BlockType.CHEST, count: 1 }
  },

  // ===== 二、工具 (Tools) =====
  
  // 木质工具
  {
    id: 'wooden_pickaxe',
    type: 'shaped',
    pattern: [
      [BlockType.PLANKS, BlockType.PLANKS, BlockType.PLANKS],
      [null, BlockType.STICK, null],
      [null, BlockType.STICK, null]
    ],
    result: { type: BlockType.WOODEN_PICKAXE, count: 1 }
  },
  {
    id: 'wooden_axe',
    type: 'shaped',
    pattern: [
      [BlockType.PLANKS, BlockType.PLANKS],
      [BlockType.PLANKS, BlockType.STICK],
      [null, BlockType.STICK]
    ],
    result: { type: BlockType.WOODEN_AXE, count: 1 }
  },
  {
    id: 'wooden_shovel',
    type: 'shaped',
    pattern: [
      [BlockType.PLANKS],
      [BlockType.STICK],
      [BlockType.STICK]
    ],
    result: { type: BlockType.WOODEN_SHOVEL, count: 1 }
  },
  {
    id: 'wooden_hoe',
    type: 'shaped',
    pattern: [
      [BlockType.PLANKS, BlockType.PLANKS],
      [null, BlockType.STICK],
      [null, BlockType.STICK]
    ],
    result: { type: BlockType.WOODEN_HOE, count: 1 }
  },

  // 石质工具
  {
    id: 'stone_pickaxe',
    type: 'shaped',
    pattern: [
      [BlockType.COBBLESTONE, BlockType.COBBLESTONE, BlockType.COBBLESTONE],
      [null, BlockType.STICK, null],
      [null, BlockType.STICK, null]
    ],
    result: { type: BlockType.STONE_PICKAXE, count: 1 }
  },
  {
    id: 'stone_axe',
    type: 'shaped',
    pattern: [
      [BlockType.COBBLESTONE, BlockType.COBBLESTONE],
      [BlockType.COBBLESTONE, BlockType.STICK],
      [null, BlockType.STICK]
    ],
    result: { type: BlockType.STONE_AXE, count: 1 }
  },
  {
    id: 'stone_shovel',
    type: 'shaped',
    pattern: [
      [BlockType.COBBLESTONE],
      [BlockType.STICK],
      [BlockType.STICK]
    ],
    result: { type: BlockType.STONE_SHOVEL, count: 1 }
  },
  {
    id: 'stone_hoe',
    type: 'shaped',
    pattern: [
      [BlockType.COBBLESTONE, BlockType.COBBLESTONE],
      [null, BlockType.STICK],
      [null, BlockType.STICK]
    ],
    result: { type: BlockType.STONE_HOE, count: 1 }
  },

  // 铁质工具
  {
    id: 'iron_pickaxe',
    type: 'shaped',
    pattern: [
      [BlockType.IRON_INGOT, BlockType.IRON_INGOT, BlockType.IRON_INGOT],
      [null, BlockType.STICK, null],
      [null, BlockType.STICK, null]
    ],
    result: { type: BlockType.IRON_PICKAXE, count: 1 }
  },
  {
    id: 'iron_axe',
    type: 'shaped',
    pattern: [
      [BlockType.IRON_INGOT, BlockType.IRON_INGOT],
      [BlockType.IRON_INGOT, BlockType.STICK],
      [null, BlockType.STICK]
    ],
    result: { type: BlockType.IRON_AXE, count: 1 }
  },
  {
    id: 'iron_shovel',
    type: 'shaped',
    pattern: [
      [BlockType.IRON_INGOT],
      [BlockType.STICK],
      [BlockType.STICK]
    ],
    result: { type: BlockType.IRON_SHOVEL, count: 1 }
  },
  {
    id: 'iron_hoe',
    type: 'shaped',
    pattern: [
      [BlockType.IRON_INGOT, BlockType.IRON_INGOT],
      [null, BlockType.STICK],
      [null, BlockType.STICK]
    ],
    result: { type: BlockType.IRON_HOE, count: 1 }
  },

  // 金质工具
  {
    id: 'gold_pickaxe',
    type: 'shaped',
    pattern: [
      [BlockType.GOLD_INGOT, BlockType.GOLD_INGOT, BlockType.GOLD_INGOT],
      [null, BlockType.STICK, null],
      [null, BlockType.STICK, null]
    ],
    result: { type: BlockType.GOLD_PICKAXE, count: 1 }
  },
  {
    id: 'gold_axe',
    type: 'shaped',
    pattern: [
      [BlockType.GOLD_INGOT, BlockType.GOLD_INGOT],
      [BlockType.GOLD_INGOT, BlockType.STICK],
      [null, BlockType.STICK]
    ],
    result: { type: BlockType.GOLD_AXE, count: 1 }
  },
  {
    id: 'gold_shovel',
    type: 'shaped',
    pattern: [
      [BlockType.GOLD_INGOT],
      [BlockType.STICK],
      [BlockType.STICK]
    ],
    result: { type: BlockType.GOLD_SHOVEL, count: 1 }
  },
  {
    id: 'gold_hoe',
    type: 'shaped',
    pattern: [
      [BlockType.GOLD_INGOT, BlockType.GOLD_INGOT],
      [null, BlockType.STICK],
      [null, BlockType.STICK]
    ],
    result: { type: BlockType.GOLD_HOE, count: 1 }
  },

  // 钻石工具
  {
    id: 'diamond_pickaxe',
    type: 'shaped',
    pattern: [
      [BlockType.DIAMOND, BlockType.DIAMOND, BlockType.DIAMOND],
      [null, BlockType.STICK, null],
      [null, BlockType.STICK, null]
    ],
    result: { type: BlockType.DIAMOND_PICKAXE, count: 1 }
  },
  {
    id: 'diamond_axe',
    type: 'shaped',
    pattern: [
      [BlockType.DIAMOND, BlockType.DIAMOND],
      [BlockType.DIAMOND, BlockType.STICK],
      [null, BlockType.STICK]
    ],
    result: { type: BlockType.DIAMOND_AXE, count: 1 }
  },
  {
    id: 'diamond_shovel',
    type: 'shaped',
    pattern: [
      [BlockType.DIAMOND],
      [BlockType.STICK],
      [BlockType.STICK]
    ],
    result: { type: BlockType.DIAMOND_SHOVEL, count: 1 }
  },
  {
    id: 'diamond_hoe',
    type: 'shaped',
    pattern: [
      [BlockType.DIAMOND, BlockType.DIAMOND],
      [null, BlockType.STICK],
      [null, BlockType.STICK]
    ],
    result: { type: BlockType.DIAMOND_HOE, count: 1 }
  },

  // 特殊工具
  {
    id: 'shears',
    type: 'shaped',
    pattern: [
      [null, BlockType.IRON_INGOT],
      [BlockType.IRON_INGOT, null]
    ],
    result: { type: BlockType.SHEARS, count: 1 }
  },
  {
    id: 'fishing_rod',
    type: 'shaped',
    pattern: [
      [null, null, BlockType.STICK],
      [null, BlockType.STICK, BlockType.STRING],
      [BlockType.STICK, null, BlockType.STRING]
    ],
    result: { type: BlockType.FISHING_ROD, count: 1 }
  },
  {
    id: 'flint_and_steel',
    type: 'shaped',
    pattern: [
      [BlockType.IRON_INGOT, null],
      [null, BlockType.FLINT]
    ],
    result: { type: BlockType.FLINT_AND_STEEL, count: 1 }
  },
  {
    id: 'compass',
    type: 'shaped',
    pattern: [
      [null, BlockType.IRON_INGOT, null],
      [BlockType.IRON_INGOT, BlockType.REDSTONE_DUST, BlockType.IRON_INGOT],
      [null, BlockType.IRON_INGOT, null]
    ],
    result: { type: BlockType.COMPASS, count: 1 }
  },
  {
    id: 'clock',
    type: 'shaped',
    pattern: [
      [null, BlockType.GOLD_INGOT, null],
      [BlockType.GOLD_INGOT, BlockType.REDSTONE_DUST, BlockType.GOLD_INGOT],
      [null, BlockType.GOLD_INGOT, null]
    ],
    result: { type: BlockType.CLOCK, count: 1 }
  },
  {
    id: 'bucket',
    type: 'shaped',
    pattern: [
      [BlockType.IRON_INGOT, null, BlockType.IRON_INGOT],
      [null, BlockType.IRON_INGOT, null]
    ],
    result: { type: BlockType.BUCKET, count: 1 }
  }
];

// ===== 三、武器与防具 (Weapons & Armor) =====

// 剑 (Sword)
const SWORD_RECIPES: CraftingRecipe[] = [
  {
    id: 'wooden_sword',
    type: 'shaped',
    pattern: [
      [BlockType.PLANKS],
      [BlockType.PLANKS],
      [BlockType.STICK]
    ],
    result: { type: BlockType.WOODEN_SWORD, count: 1 }
  },
  {
    id: 'stone_sword',
    type: 'shaped',
    pattern: [
      [BlockType.COBBLESTONE],
      [BlockType.COBBLESTONE],
      [BlockType.STICK]
    ],
    result: { type: BlockType.STONE_SWORD, count: 1 }
  },
  {
    id: 'iron_sword',
    type: 'shaped',
    pattern: [
      [BlockType.IRON_INGOT],
      [BlockType.IRON_INGOT],
      [BlockType.STICK]
    ],
    result: { type: BlockType.IRON_SWORD, count: 1 }
  },
  {
    id: 'gold_sword',
    type: 'shaped',
    pattern: [
      [BlockType.GOLD_INGOT],
      [BlockType.GOLD_INGOT],
      [BlockType.STICK]
    ],
    result: { type: BlockType.GOLD_SWORD, count: 1 }
  },
  {
    id: 'diamond_sword',
    type: 'shaped',
    pattern: [
      [BlockType.DIAMOND],
      [BlockType.DIAMOND],
      [BlockType.STICK]
    ],
    result: { type: BlockType.DIAMOND_SWORD, count: 1 }
  }
];

// 弓 (Bow)
const BOW_RECIPES: CraftingRecipe[] = [
  {
    id: 'bow',
    type: 'shaped',
    pattern: [
      [BlockType.STICK, BlockType.STRING, null],
      [BlockType.STICK, null, BlockType.STRING],
      [BlockType.STICK, BlockType.STRING, null]
    ],
    result: { type: BlockType.BOW, count: 1 }
  }
];

// 箭 (Arrow)
const ARROW_RECIPES: CraftingRecipe[] = [
  {
    id: 'arrow',
    type: 'shaped',
    pattern: [
      [BlockType.FLINT],
      [BlockType.STICK],
      [BlockType.FEATHER]
    ],
    result: { type: BlockType.ARROW, count: 4 }
  }
];

// 弩 (Crossbow)
const CROSSBOW_RECIPES: CraftingRecipe[] = [
  {
    id: 'crossbow',
    type: 'shaped',
    pattern: [
      [BlockType.STICK, BlockType.IRON_INGOT, BlockType.STICK],
      [BlockType.STRING, BlockType.TRIPWIRE_HOOK, BlockType.STRING],
      [null, BlockType.STICK, null]
    ],
    result: { type: BlockType.CROSSBOW, count: 1 }
  }
];

// 盾牌 (Shield)
const SHIELD_RECIPES: CraftingRecipe[] = [
  {
    id: 'shield',
    type: 'shaped',
    pattern: [
      [BlockType.PLANKS, BlockType.IRON_INGOT, BlockType.PLANKS],
      [BlockType.PLANKS, BlockType.PLANKS, BlockType.PLANKS],
      [null, BlockType.PLANKS, null]
    ],
    result: { type: BlockType.SHIELD, count: 1 }
  }
];

// 防具 (Armor)
const ARMOR_RECIPES: CraftingRecipe[] = [
  // 皮革防具
  {
    id: 'leather_helmet',
    type: 'shaped',
    pattern: [
      [BlockType.LEATHER, BlockType.LEATHER, BlockType.LEATHER],
      [BlockType.LEATHER, null, BlockType.LEATHER]
    ],
    result: { type: BlockType.LEATHER_HELMET, count: 1 }
  },
  {
    id: 'leather_chestplate',
    type: 'shaped',
    pattern: [
      [BlockType.LEATHER, null, BlockType.LEATHER],
      [BlockType.LEATHER, BlockType.LEATHER, BlockType.LEATHER],
      [BlockType.LEATHER, BlockType.LEATHER, BlockType.LEATHER]
    ],
    result: { type: BlockType.LEATHER_CHESTPLATE, count: 1 }
  },
  {
    id: 'leather_leggings',
    type: 'shaped',
    pattern: [
      [BlockType.LEATHER, BlockType.LEATHER, BlockType.LEATHER],
      [BlockType.LEATHER, null, BlockType.LEATHER],
      [BlockType.LEATHER, null, BlockType.LEATHER]
    ],
    result: { type: BlockType.LEATHER_LEGGINGS, count: 1 }
  },
  {
    id: 'leather_boots',
    type: 'shaped',
    pattern: [
      [BlockType.LEATHER, null, BlockType.LEATHER],
      [BlockType.LEATHER, null, BlockType.LEATHER]
    ],
    result: { type: BlockType.LEATHER_BOOTS, count: 1 }
  },

  // 铁质防具
  {
    id: 'iron_helmet',
    type: 'shaped',
    pattern: [
      [BlockType.IRON_INGOT, BlockType.IRON_INGOT, BlockType.IRON_INGOT],
      [BlockType.IRON_INGOT, null, BlockType.IRON_INGOT]
    ],
    result: { type: BlockType.IRON_HELMET, count: 1 }
  },
  {
    id: 'iron_chestplate',
    type: 'shaped',
    pattern: [
      [BlockType.IRON_INGOT, null, BlockType.IRON_INGOT],
      [BlockType.IRON_INGOT, BlockType.IRON_INGOT, BlockType.IRON_INGOT],
      [BlockType.IRON_INGOT, BlockType.IRON_INGOT, BlockType.IRON_INGOT]
    ],
    result: { type: BlockType.IRON_CHESTPLATE, count: 1 }
  },
  {
    id: 'iron_leggings',
    type: 'shaped',
    pattern: [
      [BlockType.IRON_INGOT, BlockType.IRON_INGOT, BlockType.IRON_INGOT],
      [BlockType.IRON_INGOT, null, BlockType.IRON_INGOT],
      [BlockType.IRON_INGOT, null, BlockType.IRON_INGOT]
    ],
    result: { type: BlockType.IRON_LEGGINGS, count: 1 }
  },
  {
    id: 'iron_boots',
    type: 'shaped',
    pattern: [
      [BlockType.IRON_INGOT, null, BlockType.IRON_INGOT],
      [BlockType.IRON_INGOT, null, BlockType.IRON_INGOT]
    ],
    result: { type: BlockType.IRON_BOOTS, count: 1 }
  },

  // 金质防具
  {
    id: 'gold_helmet',
    type: 'shaped',
    pattern: [
      [BlockType.GOLD_INGOT, BlockType.GOLD_INGOT, BlockType.GOLD_INGOT],
      [BlockType.GOLD_INGOT, null, BlockType.GOLD_INGOT]
    ],
    result: { type: BlockType.GOLD_HELMET, count: 1 }
  },
  {
    id: 'gold_chestplate',
    type: 'shaped',
    pattern: [
      [BlockType.GOLD_INGOT, null, BlockType.GOLD_INGOT],
      [BlockType.GOLD_INGOT, BlockType.GOLD_INGOT, BlockType.GOLD_INGOT],
      [BlockType.GOLD_INGOT, BlockType.GOLD_INGOT, BlockType.GOLD_INGOT]
    ],
    result: { type: BlockType.GOLD_CHESTPLATE, count: 1 }
  },
  {
    id: 'gold_leggings',
    type: 'shaped',
    pattern: [
      [BlockType.GOLD_INGOT, BlockType.GOLD_INGOT, BlockType.GOLD_INGOT],
      [BlockType.GOLD_INGOT, null, BlockType.GOLD_INGOT],
      [BlockType.GOLD_INGOT, null, BlockType.GOLD_INGOT]
    ],
    result: { type: BlockType.GOLD_LEGGINGS, count: 1 }
  },
  {
    id: 'gold_boots',
    type: 'shaped',
    pattern: [
      [BlockType.GOLD_INGOT, null, BlockType.GOLD_INGOT],
      [BlockType.GOLD_INGOT, null, BlockType.GOLD_INGOT]
    ],
    result: { type: BlockType.GOLD_BOOTS, count: 1 }
  },

  // 钻石防具
  {
    id: 'diamond_helmet',
    type: 'shaped',
    pattern: [
      [BlockType.DIAMOND, BlockType.DIAMOND, BlockType.DIAMOND],
      [BlockType.DIAMOND, null, BlockType.DIAMOND]
    ],
    result: { type: BlockType.DIAMOND_HELMET, count: 1 }
  },
  {
    id: 'diamond_chestplate',
    type: 'shaped',
    pattern: [
      [BlockType.DIAMOND, null, BlockType.DIAMOND],
      [BlockType.DIAMOND, BlockType.DIAMOND, BlockType.DIAMOND],
      [BlockType.DIAMOND, BlockType.DIAMOND, BlockType.DIAMOND]
    ],
    result: { type: BlockType.DIAMOND_CHESTPLATE, count: 1 }
  },
  {
    id: 'diamond_leggings',
    type: 'shaped',
    pattern: [
      [BlockType.DIAMOND, BlockType.DIAMOND, BlockType.DIAMOND],
      [BlockType.DIAMOND, null, BlockType.DIAMOND],
      [BlockType.DIAMOND, null, BlockType.DIAMOND]
    ],
    result: { type: BlockType.DIAMOND_LEGGINGS, count: 1 }
  },
  {
    id: 'diamond_boots',
    type: 'shaped',
    pattern: [
      [BlockType.DIAMOND, null, BlockType.DIAMOND],
      [BlockType.DIAMOND, null, BlockType.DIAMOND]
    ],
    result: { type: BlockType.DIAMOND_BOOTS, count: 1 }
  }
];

// ===== 四、建筑方块 (Building Blocks) =====

const BUILDING_RECIPES: CraftingRecipe[] = [
  // 楼梯 (Stairs)
  {
    id: 'wooden_stairs',
    type: 'shaped',
    pattern: [
      [BlockType.PLANKS, null, null],
      [BlockType.PLANKS, BlockType.PLANKS, null],
      [BlockType.PLANKS, BlockType.PLANKS, BlockType.PLANKS]
    ],
    result: { type: BlockType.WOODEN_STAIRS, count: 4 }
  },
  {
    id: 'stone_stairs',
    type: 'shaped',
    pattern: [
      [BlockType.COBBLESTONE, null, null],
      [BlockType.COBBLESTONE, BlockType.COBBLESTONE, null],
      [BlockType.COBBLESTONE, BlockType.COBBLESTONE, BlockType.COBBLESTONE]
    ],
    result: { type: BlockType.STONE_STAIRS, count: 4 }
  },

  // 台阶 (Slab)
  {
    id: 'wooden_slab',
    type: 'shaped',
    pattern: [
      [BlockType.PLANKS, BlockType.PLANKS, BlockType.PLANKS]
    ],
    result: { type: BlockType.WOODEN_SLAB, count: 6 }
  },
  {
    id: 'stone_slab',
    type: 'shaped',
    pattern: [
      [BlockType.COBBLESTONE, BlockType.COBBLESTONE, BlockType.COBBLESTONE]
    ],
    result: { type: BlockType.STONE_SLAB, count: 6 }
  },

  // 门 (Door)
  {
    id: 'wooden_door',
    type: 'shaped',
    pattern: [
      [BlockType.PLANKS, BlockType.PLANKS],
      [BlockType.PLANKS, BlockType.PLANKS],
      [BlockType.PLANKS, BlockType.PLANKS]
    ],
    result: { type: BlockType.WOODEN_DOOR, count: 3 }
  },
  {
    id: 'iron_door',
    type: 'shaped',
    pattern: [
      [BlockType.IRON_INGOT, BlockType.IRON_INGOT],
      [BlockType.IRON_INGOT, BlockType.IRON_INGOT],
      [BlockType.IRON_INGOT, BlockType.IRON_INGOT]
    ],
    result: { type: BlockType.IRON_DOOR, count: 3 }
  },

  // 活板门 (Trapdoor)
  {
    id: 'wooden_trapdoor',
    type: 'shaped',
    pattern: [
      [BlockType.PLANKS, BlockType.PLANKS, BlockType.PLANKS],
      [BlockType.PLANKS, BlockType.PLANKS, BlockType.PLANKS]
    ],
    result: { type: BlockType.WOODEN_TRAPDOOR, count: 2 }
  },
  {
    id: 'iron_trapdoor',
    type: 'shaped',
    pattern: [
      [BlockType.IRON_INGOT, BlockType.IRON_INGOT, BlockType.IRON_INGOT],
      [BlockType.IRON_INGOT, BlockType.IRON_INGOT, BlockType.IRON_INGOT]
    ],
    result: { type: BlockType.IRON_TRAPDOOR, count: 2 }
  },

  // 栅栏 (Fence)
  {
    id: 'wooden_fence',
    type: 'shaped',
    pattern: [
      [BlockType.PLANKS, BlockType.STICK, BlockType.PLANKS],
      [BlockType.PLANKS, BlockType.STICK, BlockType.PLANKS]
    ],
    result: { type: BlockType.WOODEN_FENCE, count: 3 }
  },

  // 玻璃板 (Glass Pane)
  {
    id: 'glass_pane',
    type: 'shaped',
    pattern: [
      [BlockType.GLASS, BlockType.GLASS, BlockType.GLASS],
      [BlockType.GLASS, BlockType.GLASS, BlockType.GLASS]
    ],
    result: { type: BlockType.GLASS_PANE, count: 16 }
  },

  // 铁栏杆 (Iron Bars)
  {
    id: 'iron_bars',
    type: 'shaped',
    pattern: [
      [BlockType.IRON_INGOT, BlockType.IRON_INGOT, BlockType.IRON_INGOT],
      [BlockType.IRON_INGOT, BlockType.IRON_INGOT, BlockType.IRON_INGOT]
    ],
    result: { type: BlockType.IRON_BARS, count: 16 }
  },

  // 书架 (Bookshelf)
  {
    id: 'bookshelf',
    type: 'shaped',
    pattern: [
      [BlockType.PLANKS, BlockType.PLANKS, BlockType.PLANKS],
      [BlockType.BOOK, BlockType.BOOK, BlockType.BOOK],
      [BlockType.PLANKS, BlockType.PLANKS, BlockType.PLANKS]
    ],
    result: { type: BlockType.BOOKSHELF, count: 1 }
  }
];

// ===== 五、红石与运输 (Redstone & Transportation) =====

const REDSTONE_RECIPES: CraftingRecipe[] = [
  // 红石火把 (Redstone Torch)
  {
    id: 'redstone_torch',
    type: 'shaped',
    pattern: [
      [BlockType.REDSTONE_DUST],
      [BlockType.STICK]
    ],
    result: { type: BlockType.REDSTONE_TORCH, count: 1 }
  },

  // 红石中继器 (Redstone Repeater)
  {
    id: 'redstone_repeater',
    type: 'shaped',
    pattern: [
      [BlockType.REDSTONE_TORCH, BlockType.REDSTONE_DUST, BlockType.REDSTONE_TORCH],
      [BlockType.STONE, BlockType.STONE, BlockType.STONE]
    ],
    result: { type: BlockType.REDSTONE_REPEATER, count: 1 }
  },

  // 红石比较器 (Redstone Comparator)
  {
    id: 'redstone_comparator',
    type: 'shaped',
    pattern: [
      [null, BlockType.REDSTONE_TORCH, null],
      [BlockType.REDSTONE_TORCH, BlockType.NETHER_QUARTZ, BlockType.REDSTONE_TORCH],
      [BlockType.STONE, BlockType.STONE, BlockType.STONE]
    ],
    result: { type: BlockType.REDSTONE_COMPARATOR, count: 1 }
  },

  // 活塞 (Piston)
  {
    id: 'piston',
    type: 'shaped',
    pattern: [
      [BlockType.PLANKS, BlockType.PLANKS, BlockType.PLANKS],
      [BlockType.COBBLESTONE, BlockType.IRON_INGOT, BlockType.COBBLESTONE],
      [BlockType.COBBLESTONE, BlockType.REDSTONE_DUST, BlockType.COBBLESTONE]
    ],
    result: { type: BlockType.PISTON, count: 1 }
  },

  // 粘性活塞 (Sticky Piston)
  {
    id: 'sticky_piston',
    type: 'shaped',
    pattern: [
      [BlockType.SLIME_BALL],
      [BlockType.PISTON]
    ],
    result: { type: BlockType.STICKY_PISTON, count: 1 }
  },

  // 动力铁轨 (Powered Rail)
  {
    id: 'powered_rail',
    type: 'shaped',
    pattern: [
      [BlockType.GOLD_INGOT, null, BlockType.GOLD_INGOT],
      [BlockType.GOLD_INGOT, BlockType.STICK, BlockType.GOLD_INGOT],
      [BlockType.GOLD_INGOT, BlockType.REDSTONE_DUST, BlockType.GOLD_INGOT]
    ],
    result: { type: BlockType.POWERED_RAIL, count: 6 }
  },

  // 探测铁轨 (Detector Rail)
  {
    id: 'detector_rail',
    type: 'shaped',
    pattern: [
      [BlockType.IRON_INGOT, null, BlockType.IRON_INGOT],
      [BlockType.IRON_INGOT, BlockType.STONE_PRESSURE_PLATE, BlockType.IRON_INGOT],
      [BlockType.IRON_INGOT, BlockType.REDSTONE_DUST, BlockType.IRON_INGOT]
    ],
    result: { type: BlockType.DETECTOR_RAIL, count: 6 }
  }
];

const TRANSPORTATION_RECIPES: CraftingRecipe[] = [
  // 矿车 (Minecart)
  {
    id: 'minecart',
    type: 'shaped',
    pattern: [
      [BlockType.IRON_INGOT, null, BlockType.IRON_INGOT],
      [BlockType.IRON_INGOT, BlockType.IRON_INGOT, BlockType.IRON_INGOT]
    ],
    result: { type: BlockType.MINECART, count: 1 }
  },

  // 船 (Boat)
  {
    id: 'boat',
    type: 'shaped',
    pattern: [
      [BlockType.PLANKS, null, BlockType.PLANKS],
      [BlockType.PLANKS, BlockType.PLANKS, BlockType.PLANKS]
    ],
    result: { type: BlockType.BOAT, count: 1 }
  }
];

// 合并所有配方
BASIC_RECIPES.push(
  ...SWORD_RECIPES,
  ...BOW_RECIPES,
  ...ARROW_RECIPES,
  ...CROSSBOW_RECIPES,
  ...SHIELD_RECIPES,
  ...ARMOR_RECIPES,
  ...BUILDING_RECIPES,
  ...REDSTONE_RECIPES,
  ...TRANSPORTATION_RECIPES
);

// 配方分类，便于管理和扩展
export const RECIPE_CATEGORIES = {
  BASIC: [
    'planks_from_log', 'crafting_table', 'stick', 'torch_coal', 'torch_charcoal', 
    'furnace', 'chest'
  ],
  TOOLS: [
    'wooden_pickaxe', 'wooden_axe', 'wooden_shovel', 'wooden_hoe',
    'stone_pickaxe', 'stone_axe', 'stone_shovel', 'stone_hoe',
    'iron_pickaxe', 'iron_axe', 'iron_shovel', 'iron_hoe',
    'gold_pickaxe', 'gold_axe', 'gold_shovel', 'gold_hoe',
    'diamond_pickaxe', 'diamond_axe', 'diamond_shovel', 'diamond_hoe',
    'shears', 'fishing_rod', 'flint_and_steel', 'compass', 'clock', 'bucket'
  ],
  WEAPONS: [
    'wooden_sword', 'stone_sword', 'iron_sword', 'gold_sword', 'diamond_sword',
    'bow', 'arrow', 'crossbow', 'shield'
  ],
  ARMOR: [
    'leather_helmet', 'leather_chestplate', 'leather_leggings', 'leather_boots',
    'iron_helmet', 'iron_chestplate', 'iron_leggings', 'iron_boots',
    'gold_helmet', 'gold_chestplate', 'gold_leggings', 'gold_boots',
    'diamond_helmet', 'diamond_chestplate', 'diamond_leggings', 'diamond_boots'
  ],
  BUILDING: [
    'wooden_stairs', 'stone_stairs', 'wooden_slab', 'stone_slab',
    'wooden_door', 'iron_door', 'wooden_trapdoor', 'iron_trapdoor',
    'wooden_fence', 'glass_pane', 'iron_bars', 'bookshelf'
  ],
  REDSTONE: [
    'redstone_torch', 'redstone_repeater', 'redstone_comparator',
    'piston', 'sticky_piston', 'powered_rail', 'detector_rail'
  ],
  TRANSPORTATION: [
    'minecart', 'boat'
  ]
};

// 获取特定分类的配方
export function getRecipesByCategory(category: keyof typeof RECIPE_CATEGORIES): CraftingRecipe[] {
  const recipeIds = RECIPE_CATEGORIES[category];
  return BASIC_RECIPES.filter(recipe => recipeIds.includes(recipe.id));
}

// 根据结果物品类型查找配方
export function getRecipesByResult(blockType: BlockType): CraftingRecipe[] {
  return BASIC_RECIPES.filter(recipe => recipe.result.type === blockType);
}

// 根据材料查找可能的配方
export function getRecipesByMaterial(blockType: BlockType): CraftingRecipe[] {
  return BASIC_RECIPES.filter(recipe => {
    return recipe.pattern.some(row => 
      row.some(item => item === blockType)
    );
  });
}

// 搜索配方（根据名称或ID）
export function searchRecipes(query: string): CraftingRecipe[] {
  const lowerQuery = query.toLowerCase();
  return BASIC_RECIPES.filter(recipe => 
    recipe.id.toLowerCase().includes(lowerQuery)
  );
}

// 获取所有配方的统计信息
export function getRecipeStats() {
  return {
    total: BASIC_RECIPES.length,
    categories: Object.keys(RECIPE_CATEGORIES).length,
    byCategory: Object.entries(RECIPE_CATEGORIES).map(([name, recipes]) => ({
      name,
      count: recipes.length
    }))
  };
}